/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.java.editor;

import com.java.mapbean.Theloai1;
import com.java.service.TheLoai1Service;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author quannq
 */
public class TheLoai1Editor extends PropertyEditorSupport {

    public TheLoai1Service theLoai1Service;

    public TheLoai1Editor(TheLoai1Service theloai1Service) {
        super();
        this.theLoai1Service = theloai1Service;
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (!text.equals("")) {
            Theloai1 emp = theLoai1Service.findId(Integer.parseInt(text));
            setValue(emp);
        } else {
            setValue(null);
        }
    }
}
